package com.sky.mapper;

import com.sky.dto.ReportQueryDTO;
import com.sky.entity.Orders;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

@Mapper
public interface ReportMapper {
    @Select("select * from orders where DATE(order_time)>=#{begin} and DATE(order_time)<=#{end} and status!=1")
    List<Orders> queryOrders(ReportQueryDTO reportQueryDTO);

    @Select("select count(*) as count from orders where DATE(order_time)=#{date} and status!=1")
    Integer queryOrdersCount(String date);

    @Select("select count(*) as count from orders where DATE(order_time)=#{date} and status=5")
    Integer queryValidOrdersCount(String date);

    @Select("select * from orders where status!=1")
    List<Orders> queryOrders1();
    @Select("select sum(amount) as amount from orders where DATE(order_time)=#{date} and status=5")
    BigDecimal queryComplateOrders(String date);

    @Select("select count(id) as count from orders where DATE(order_time)=#{date} and status=5")
    Integer queryComplateOrdersCount(String date);

    @Select("SELECT od.name,SUM(od.number) as number FROM order_detail od,orders o WHERE od.order_id=o.id and o.status=5 and DATE(o.order_time)>=#{begin} and DATE(o.order_time)<=#{end} GROUP BY  name ORDER BY number DESC LIMIT 10")
    List<Map> queryTop10(ReportQueryDTO reportQueryDTO);
    @Select("select count(id) as count from user where DATE(create_time)<=#{item}")
    Map queryTotal(String item);
    @Select("select count(*) as count from user where DATE(create_time)=#{time}")
    Integer querynewUser(String time);
    @Select("select SUM(amount) as amount from orders where DATE(order_time)>=#{begin} and DATE(order_time)<=#{end} and status=5")
    BigDecimal queryComplateOrdersCountNow(ReportQueryDTO reportQueryDTO);
    @Select("select count(id) as count from setmeal where status=#{status}")
    Integer querySetmealCount(int status);
    @Select("select count(id) as count from dish where status=#{status}")
    Integer queryDishCount(int status);


}
